import { defineStore } from 'pinia'
import { ref } from 'vue'
import { Details } from '@/api/member'
export const useMemberStore = defineStore('member', () => {
  const member = ref<Member>() // 用户名
  if(member.value == null) {
    Details().then(res => {
      member.value = res.data
    })
  }
  const setMemberToken = (data: MemberToken) => {
    uni.setStorageSync('mobiletoken', data.accessToken)
    uni.setStorageSync('mobileRefreshToken', data.refreshToken)
    member.value = data.member
  }

  return { member, setMemberToken }
})